<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    手机号：<input type="text"> <button>获取验证码</button>
    <script>
        // 需要倒计时3秒
        let time = 3;
        const btn = document.querySelector("button");
        btn.addEventListener("click", function () {
            this.disabled = true; //设置为无法再次点击
            const setInterval1 = setInterval(function () {
                if (time != 0) {
                    btn.innerText = "等待" + time + "再次点击";
                    time--;
                } else {
                    clearInterval(setInterval1);
                    btn.disabled = false;
                    btn.innerText = "获取验证码";
                    time = 3;
                }
            }, 1000);
        });
    </script>
</body>

</html>